package com.ruoyi.base.utils.number;

import java.math.BigDecimal;
import java.util.Random;

/**
 * 数字工具类
 *
 * @author lcf
 */
public class NumberUtils {

    /**
     * 检查是否为空
     */
    public static boolean isEmpty(Long id) {
        return id == null || id == 0;
    }

    /**
     * 检查是否为空
     */
    public static boolean isEmpty(Integer id) {
        return id == null || id == 0;
    }

    /**
     * 检查是否为空
     */
    public static boolean isEmpty(Double value) {
        return value == null || value == 0;
    }

    /**
     * 检查是否为空
     */
    public static boolean isEmpty(BigDecimal value) {
        return value == null || BigDecimal.ZERO.compareTo(value) == 0;
    }

    /**
     * 检查是否为空
     */
    public static boolean isNotEmpty(BigDecimal value) {
        return !isEmpty(value);
    }

    /**
     * 检查是否为空
     */
    public static boolean isNotEmpty(Double value) {
        return !isEmpty(value);
    }

    /**
     * 检查是否为空
     */
    public static boolean isNotEmpty(Long id) {
        return !isEmpty(id);
    }

    /**
     * 检查是否为空
     */
    public static boolean isNotEmpty(Integer id) {
        return !isEmpty(id);
    }

    /**
     * 产生随机数
     */
    public static String randomInt(int amount) {
        Random ran = new Random();
        StringBuilder stringBuffer = new StringBuilder();
        for (int i = 0; i < amount; i++) {
            stringBuffer.append(ran.nextInt(10));
        }

        return stringBuffer.toString();
    }
}
